package blog

import (
	"encoding/xml"
)

type AtomAuthor struct {
	XMLName xml.Name `xml:"author"`
	Name    string   `xml:"name"`
	Uri     string   `xml:"uri"`
	Email   string   `xml:"email"`
}
type EntryLink struct {
	XMLName xml.Name `xml:"link"`
	Url     string   `xml:"href,attr"`
}

type Entry struct {
	XMLName   xml.Name `xml:"entry"`
	Id        string   `xml:"id"`
	Title     string   `xml:"title"`
	Published string   `xml:"published"`
	Updated   string   `xml:"updated"`
	Link      EntryLink
	Summary   struct {
		XMLName xml.Name `xml:"summary"`
		Value   string   `xml:",chardata"`
		Type    string   `xml:"type,attr"`
	}
}

type Atom struct {
	XMLName   xml.Name `xml:"feed"`
	XMLNS     string   `xml:"xmlns,attr"`
	Title     string   `xml:"title"`
	SubTitle  string   `xml:"subtitle"`
	Author    AtomAuthor
	Id        string `xml:"id"`
	Generator string `xml:"generator"`
	Published string `xml:"published"`
	Updated   string `xml:"updated"`
	Entry     []Entry
}

func NewAtom() *Atom {
	return &Atom{XMLNS: "http://www.w3.org/2005/Atom"}
}
